function wxpay(app, money, orderId, redirectUrl) {
  let remark = '';
  let nextAction = {};
  if (orderId != 0) {
    remark = "支付订单 ：" + orderId;
  }
  wx.request({
    url: app.globalData._path + app.globalData.subDomain + '/payment/unifiedOrder',
    data: {
      token: wx.getStorageSync('token'),
      uid: wx.getStorageSync('uid'),
      money:money,
      remark: remark,
      payName:"在线支付",
      order_id: orderId,
      channel:'weixin'
    },
    //method:'POST',
    success: function(res){
      if(res.data.code == 0){
        // 发起支付
        wx.requestPayment({
          timeStamp: res.data.list[0].sign.timeStamp,
          nonceStr: res.data.list[0].sign.nonceStr,
          package: 'prepay_id=' + res.data.list[0].sign.prepay_id,
          signType:'MD5',
          paySign: res.data.list[0].sign.sign,
          fail:function (aaa) {
            console.log(aaa);
            wx.showToast({title: '支付失败:' + aaa})
          },
          success:function () {
            wx.showToast({title: '支付成功'})
            wx.redirectTo({
              url: redirectUrl
            });
          }
        })
      } else {
        wx.showModal({
          title: '出错了',
          content: res.data.list,
          showCancel: false,
          success: function (res) {

          }
        })
      }
    }
  })
}

module.exports = {
  wxpay: wxpay
}
